// ScriptCAPI.h: interface for the CScriptCAPI class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_SCRIPTCAPI_H__AB1E1F9D_AE94_402E_AA94_5E8D08BBF49B__INCLUDED_)
#define AFX_SCRIPTCAPI_H__AB1E1F9D_AE94_402E_AA94_5E8D08BBF49B__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <tchar.h>

#ifndef PGLCAPI_EXT_CLASS
	#ifdef _PGLMFC_DLL
		#define PGLCAPI_EXT_CLASS _declspec(dllexport)
	#else
		#define PGLCAPI_EXT_CLASS _declspec(dllimport)
	#endif
#endif

#ifndef LPCTSTR
	#define LPCTSTR const TCHAR* 
#endif

/*! \name External C Interface to CPGLScript

  \ingroup ScriptGroup
*/
//@{
#if defined(__cplusplus)
extern "C"
{
#endif

/*!\brief Initializes the C API
	
	\param bInitGDIp true if GDI+ has to be initialized,
	\param bInitCOM true if COM has to be initialized
*/
PGLCAPI_EXT_CLASS	int pglInit(int bInitGDIp = true, int bInitCOM = true);

/*! \brief Closes the C API

  \param bCloseCOM true if COM has to be closed
*/
PGLCAPI_EXT_CLASS	int pglQuit(int bCloseCOM = true);

/*! \brief Creates a figure

  \return dialog ID
  \sa CPGLScript::Figure
*/
PGLCAPI_EXT_CLASS	long pglFigure();

/*! \brief Creates a stand alone region

  \return region ID
  \sa CPGLScript::Region
*/
PGLCAPI_EXT_CLASS	long pglRegion();

/*! \brief Returns the current region ID

  \return current region ID
  \sa CPGLScript::GetCR
*/
PGLCAPI_EXT_CLASS	long pglGetCR();

/*! \brief Sets the current region ID

  \return the current region ID
  \sa CPGLScript::SetCR
*/
PGLCAPI_EXT_CLASS	int  pglSetCR(long dwRegionID);

/*! \brief returns the current dialog ID

  \return current dialog ID
  \sa CPGLScript::GetCD
*/
PGLCAPI_EXT_CLASS	long pglGetCD();

/*! \brief Shows a modal dialog

  \param lRegionID region to show
  \param szFlags dialog flags 
  \return value returned by DoModal

 \par Flag description:
The flag string is a combination of chacters:

	- a disable auto zoom,
	- t triple buffering,
	- o no toolbal,
	- k no taskbar,
	- m clipboard metafile

	\sa CPGLScript::DoModalRegion
*/
PGLCAPI_EXT_CLASS	int pglDoModalRegion(long lRegionID, LPCTSTR szFlags);

/*! \brief Closes a figure

  \param lID dialog ID to close
  \sa CPGLScript::CloseFigure
*/
PGLCAPI_EXT_CLASS	void pglCloseFigure( long lID);

/*! \brief Closes all figures

  \sa CPGLScript::CloseAllFigures
*/
PGLCAPI_EXT_CLASS	void pglCloseAllFigures();

/*! \brief Close a stand alone region

  \param lRegionID region ID to close
  \sa CPGLScript::CloseRegion
*/
PGLCAPI_EXT_CLASS	void pglCloseRegion( long lRegionID);

/*! \brief Closes all stand alone regions

  \sa CPGLScript::CloseAllRegions
*/
PGLCAPI_EXT_CLASS	void pglCloseAllRegions();


/*! \brief returns the number of object in a region

	\param lRegionID region ID
	\return number of objects
  \sa CPGLScript::GetObjectSize
*/
PGLCAPI_EXT_CLASS	long pglGetObjectsSize( long lRegionID);

/*! \brief returns the ID of the uIndex object

  \param lRegionID region ID
  \param uIndex index of the object
  \return object ID

  \sa CPGLScript::GetObject
*/
PGLCAPI_EXT_CLASS	long pglGetObject( long lRegionID, long uIndex );

/*! \brief removes the uIndex object in the region

  \param lRegionID region ID
  \param uIndex index of the object
  
  \sa CPGLScript::RemoveObject
*/
PGLCAPI_EXT_CLASS	void pglRemoveObject( long lRegionID, long uIndex );


/*! \brief returns the number of child regions in a region

  \param lRegionID region ID
  \return number of children

  \sa CPGLScript::GetChildrenSize
*/
PGLCAPI_EXT_CLASS	long pglGetChildrenSize( long lRegionID );

/*! \brief returns the ID of the uIndex child

  \param lRegionID region ID
  \param uIndex index of the child
  \return object ID

  \sa CPGLScript::GetObject
*/
PGLCAPI_EXT_CLASS	long pglGetChild( long lRegionID, long uIndex );

/*! \brief removes the uIndex child off the region

  \param lRegionID region ID
  \param uIndex index of the child
  
  \sa CPGLScript::RemoveObject
*/
PGLCAPI_EXT_CLASS	void pglRemoveChild( long lRegionID, long uIndex );


/*! \brief divides the region in an array of childs

  \param lRegionID region ID
  \param nRows number of rows
  \param nCols number of columns
  \sa CPGLScript::Divide
*/
PGLCAPI_EXT_CLASS	long pglDivide(long lRegionID, long nRows, long nCols);


/*! \brief divides and create a complex child layout

  \param lRegionID region ID
  \param szLayout layout description
  \sa CPGLScript::Layout
*/
PGLCAPI_EXT_CLASS	long pglLayout(long lRegionID, LPCTSTR szLayout);

/*! \brief return the ID of the parent

  \param lObjectID object ID
  \return ID of the parent, 0 if no parent
  \sa CPGLScript::GetParent
*/
PGLCAPI_EXT_CLASS	long pglGetParent(long lObjectID );

/*! \brief updates the current region to its parent

  \return current region ID 
  \sa CPGLScript::OutOfChild
*/
PGLCAPI_EXT_CLASS   long pglOutOfChild();


/*! \brief Plots a line

  \param lRegionID region ID to add a line
  \param nPoints number of points
  \param pX array of float containing the x coordinates
  \param pY array of float containing the y coordinates
  \param szFlags appearance format string

  pX and pY size must be greater or equal to nPoints

  \sa CPGLScript::Plot
*/
PGLCAPI_EXT_CLASS	long pglPlot(
    long lRegionID, 
    long nPoints, 
    float* pX, 
    float* pY, 
    LPCTSTR szFlags,
    bool makeCopy
    );

/*! \brief Plots a line, with x coordinates linearly spaced

  \param lRegionID region ID to add a line
  \param nPoints number of points
  \param fX0 \f$x[0]\f$
  \param fXStep x step ( \f$x[i+1]-x[i]\f$ )
  \param pY array of float containing the y coordinates
  \param szFlags appearance format string
  \param makeCopy true if internal copy of the data is made, false only the address is kept. 

  pY size must be greater or equal to nPoints

  If you choose to copy the address, you must take care of the cleaning.

  \sa CPGLScript::PlotY
*/
PGLCAPI_EXT_CLASS	long pglPlotY(
	long lRegionID, 
	long nPoints, 
	float fX0, 
	float fXStep, 
	float* pY, 
	LPCTSTR szFlags,
    bool makeCopy
    );


/*! \brief Approximates and Plots a line 

  \param lRegionID region ID to add a line
  \param nPoints number of points
  \param pX array of float containing the x coordinates
  \param pY array of float containing the y coordinates
  \param fCompressionRation [0...1] is the ration between the number of approximated points over the real number of points
  \param szFlags appearance format string

  pX and pY size must be greater or equal to nPoints

  \sa CPGLScript::Plot, CPGLScript::PlotLOD, pglPlot
*/
PGLCAPI_EXT_CLASS	long pglPlotLOD(
    long lRegionID, 
    long nPoints,
    float* pX, 
    float* pY, 
    float fCompressionRatio, 
    LPCTSTR szFlags,
    bool makeCopy
    );

/*! \brief Approximates and Plots a line , with x coordinates linearly spaced

  \param lRegionID region ID to add a line
  \param nPoints number of points
  \param fX0 \f$x[0]\f$
  \param fXStep x step ( \f$x[i+1]-x[i]\f$ )
  \param pY array of float containing the y coordinates
  \param fCompressionRation [0...1] is the ration between the number of approximated points over the real number of points
  \param szFlags appearance format string

  pY size must be greater or equal to nPoints

  \sa CPGLScript::PlotLODY, CPGLScript::PlotY
*/
PGLCAPI_EXT_CLASS	long pglPlotLODY(
    long lRegionID, 
    long nPoints, 
    float fX0, 
    float fXStep, 
    float* pY, 
    float fCompressionRatio, 
    LPCTSTR szFlags,
    bool makeCopy
    );


/*! \brief Plots a mathematical function

  \param lRegionID region ID to add a line
  \param nPoints number of points
  \param pX array of float containing the x coordinates
  \param szFcnX string describing the math function
  \param szFlags appearance format string

  pX size must be greater or equal to nPoints.

  szFcnX must be a mono-variable function of \f$x\f$.

  \sa CPGLScript::PlotFcn
*/
PGLCAPI_EXT_CLASS	long pglPlotFcn(
    long lRegionID, 
    long nPoints, 
    float* pX, 
    LPCTSTR szFcnX, 
    LPCTSTR szFlags,
    bool makeCopy
    );

/*! \brief Plots a mathematical function, with linearly spaced x coordinate

  \param lRegionID region ID to add a line
  \param nPoints number of points
  \param fX0 \f$x[0]\f$
  \param fXStep x step ( \f$x[i+1]-x[i]\f$ )
  \param szFcnX string describing the math function
  \param szFlags appearance format string

  pX size must be greater or equal to nPoints.

  szFcnX must be a mono-variable function of \f$x\f$.

  \sa CPGLScript::PlotFcnY
*/
PGLCAPI_EXT_CLASS	long pglPlotFcnY(
     long lRegionID, 
     long nPoints, 
     float fX0, 
     float fXStep, 
     LPCTSTR szFcnX, 
     LPCTSTR szFlags
     );


/*! \brief Plots an horizontal line

  \param lRegionID region ID to add a line
  \param fY \f$y\f$ coordinate of the line
  \param szFlags appearance format string

  \sa CPGLScript::PlotHor, CPGLScript::PlotVer
*/
PGLCAPI_EXT_CLASS	long pglPlotHor(
    long lRegionID, 
    float fY, 
    LPCTSTR szFlags
    );

/*! \brief Plots an vertical line

  \param lRegionID region ID to add a line
  \param fX \f$x\f$ coordinate of the line
  \param szFlags appearance format string

  \sa CPGLScript::PlotHor, CPGLScript::PlotVer
*/
PGLCAPI_EXT_CLASS	long pglPlotVer(
    long lRegionID,
    float fX, 
    LPCTSTR szFlags
    );


/*! \brief Plot an histogram of data

  \param lRegionID region ID to add an histogram
  \param nPoints number of points
  \param pY array of float describing the points
  \param szFlags appearance format string

  pY size must be greater or equal to nPoints.
  
  \sa CPGLScript::Histogram
*/
PGLCAPI_EXT_CLASS	long pglHistogram(
    long lRegionID, 
    long nPoints, 
    float* pY, 
    LPCTSTR szFlags,
    bool makeCopy
    );


/*! \brief Plot an error bar

  \sa CPGLScript::ErrorBar
*/
PGLCAPI_EXT_CLASS	long pglErrorBar(
    long lRegionID, 
    long nPoints, 
    float* pX, 
    float* pY, 
    float* pErrorUp, 
    float* pErrorDown, 
    LPCTSTR szFlags,
    bool makeCopy
    );

/*! \brief Plot a linearly spaced error bar

  \sa CPGLScript::ErrorBar
*/
PGLCAPI_EXT_CLASS	long pglErrorBarY(
    long lRegionID, 
    long nPoints, 
    float fX0, 
    float fXStep, 
    float* pY, 
    float* pErrorUp, 
    float* pErrorDown, 
    LPCTSTR szFlags,
    bool makeCopy
    );


/*! \brief Plot a scatter of points

  \sa CPGLScript::Scatter
*/
PGLCAPI_EXT_CLASS	long pglScatter(
    long lRegionID, 
    long nPoints, 
    float* pX, 
    float* pY, 
    float* pValues, 
    LPCTSTR szFlags,
    bool makeCopy
    );

/*! \brief A stock chart

  \sa CPGLScript::Stock
*/
PGLCAPI_EXT_CLASS	long pglStock(
    long lRegionID, 
    long nPoints, 
    float fX0, 
    float fXStep, 
    float* pOpen, 
    float* pHigh, 
    float* pLow, 
    float* pClose, 
    LPCTSTR szFlags,
    bool makeCopy
    );

/*! \brief A candlesitch chart

  \sa CPGLScript::CandleStick
*/
PGLCAPI_EXT_CLASS	long pglCandleStick(
    long lRegionID, 
    long nPoints, 
    float fX0, 
    float fXStep, 
    float* pOpen, 
    float* pHigh, 
    float* pLow, 
    float* pClose, 
    LPCTSTR szFlags,
    bool makeCopy
    );


/*! \brief An image

  \sa CPGLScript::Image
*/
PGLCAPI_EXT_CLASS	long pglImage(
    long lRegionID, 
    LPCTSTR szFileName, 
    LPCTSTR szFlags
    );


/*! \brief Sets property of an object

  \sa CPGLScript::Set
*/
PGLCAPI_EXT_CLASS   void pglSet(long uObjectID, LPCTSTR szPropAndValues);

/*! \brief Gets the property of an object

	ppStr is a pointer to a TCHAR*. 
	If successful, memory is allocated to hold the resulting string and the cleaning must be handled by the user. 
	If not successful, ppStr is set to NULL.

  \sa CPGLScript::Get
*/
PGLCAPI_EXT_CLASS	void pglGet(long uObjectID, LPCTSTR szProperty, TCHAR** ppStr);

/*! \brief Returns help string about object

  ppStr is a pointer to a TCHAR*. 
  If successful, memory is allocated to hold the resulting string and the cleaning must be handled by the user. 
  If not successful, ppStr is set to NULL.
  
  \sa CPGLScript::Helpet
*/
PGLCAPI_EXT_CLASS	void pglGetHelp(long uObjectID, TCHAR** ppStr);


/*! \brief Sets the left label

  \sa CPGLScript::LeftLabel
*/
PGLCAPI_EXT_CLASS	long pglLeftLabel(long lRegionID, LPCTSTR szLabel);

/*! \brief Sets the bottom label

  \sa CPGLScript::BottomLabel
*/
PGLCAPI_EXT_CLASS	long pglBottomLabel(long lRegionID, LPCTSTR szLabel);

/*! \brief Sets the top label (title)

  \sa CPGLScript::Title
*/
PGLCAPI_EXT_CLASS	long pglTitle(long lRegionID, LPCTSTR szLabel);

/*! \brief Sets the right label
 
  \sa CPGLScript::RightLabel
*/
PGLCAPI_EXT_CLASS	long pglRightLabel(long lRegionID, LPCTSTR szLabel);


/*! \brief Adds a legend

  \sa CPGLScript::Legend
*/
PGLCAPI_EXT_CLASS	long pglLegend(long lRegionID);


/*! \brief Zoom extent of the objects

  \sa CPGLScript::ZoomAll
*/
PGLCAPI_EXT_CLASS	void pglZoomAll(long lRegionID, int bRecurse);

/*! \brief Zoom a world region

  \sa CPGLScript::Zoom
*/
PGLCAPI_EXT_CLASS	void pglZoom(
	long lRegionID, 
	double dLeft, 
	double dTop, 
	double dRight, 
	double dBottom);

/*! \brief Returns current zoom extent

  \sa CPGLScript::GetZoom
*/
PGLCAPI_EXT_CLASS	int	 pglGetZoom(
	long lRegionID, 
	double* pLeft, 
	double* pBottom, 
	double* pRight, 
	double* pTop
	);

/*! \brief Sets auto-zoom state

  \sa CPGLScript::AutoZoom
*/
PGLCAPI_EXT_CLASS	void pglAutoZoom(LPCTSTR szState );


/*! \brief Load region from xml file

  \sa CPGLScript::LoadFromXML
*/
PGLCAPI_EXT_CLASS	long pglLoadFromXML(
    long lRegionID, 
    LPCTSTR szFileName 
    );

/*! \brief Save to xml file

  \sa CPGLScript::SaveToXML
*/
PGLCAPI_EXT_CLASS	int pglSaveToXML(
    long lRegionID, 
    LPCTSTR szFileName, 
    int bZipping 
    );

/*! \brief Output to diverse graphic formats

  \sa CPGLScript::RenderToFile
*/
PGLCAPI_EXT_CLASS	int pglRenderToFile(
    long lRegionID, 
    LPCTSTR szFileName, 
    LPCTSTR szFormat 
    );

/*! \brief Output to memory bitmap

*/
PGLCAPI_EXT_CLASS	int pglRenderToBitmap(
	long lRegionID, 
	unsigned int width_,
	unsigned int height_,
	unsigned int stride_,
	unsigned int bpp_,
	char* bits,
    LPCSTR szFormat
	);

/*! \brief Loads a comma separated file

  \sa CPGLScript::LoadCSVFile
*/
PGLCAPI_EXT_CLASS	int pglLoadCSVFile( 
    long lRegionID, 
    LPCTSTR szFileName
    );

#if defined(__cplusplus)
};
#endif

//@}


#endif // !defined(AFX_SCRIPTCAPI_H__AB1E1F9D_AE94_402E_AA94_5E8D08BBF49B__INCLUDED_)
